﻿using Basic.FormModel.DB;
using Basic.FormRemoteModel.Page.Model;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.IdGenerator;
using WeDonekRpc.Model;
using WeDonekRpc.SqlSugar;

namespace Basic.FormDAL.Repository
{
    internal class CustomPageDAL : BasicDAL<DBCustomPage, long>, ICustomPageDAL
    {
        public CustomPageDAL ( IRepository<DBCustomPage> basicDAL ) : base(basicDAL, "custom.page")
        {
        }
        public Result[] Query<Result> ( PageQueryParam query, IBasicPage paging, out int count ) where Result : class
        {
            paging.InitOrderBy("Id", true);
            return this._BasicDAL.Query<Result>(query.ToWhere(), paging, out count);
        }
        public long Add ( PageAdd data )
        {
            DBCustomPage add = data.ConvertMap<PageAdd, DBCustomPage>();
            add.Id = IdentityHelper.CreateId();
            add.CreateTime = DateTime.Now;
            this._BasicDAL.Insert(add);
            return add.Id;
        }
    }
}
